package com.xhf.kl;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.xhf.kl.utils.DensityUtils;
import com.xhf.kl.utils.StatusBarCompat;
import com.xhf.kl.widget.CircularRingPercentageView;

public class PeidaiActivity extends AppCompatActivity implements View.OnClickListener{

    private LinearLayout ll_pd;//包裹文字和图片
    private TextView tv_pd;
    private TextView tv_pd_title;
    private TextView tv_pd_details;
    private RelativeLayout rl_view;//包裹心率控件
    private CircularRingPercentageView circularRingPercentageView;
    private TextView tv_xl;

    private TextView tv_back,tv_bmp,tv_dangqian,tv_max_xl;


    private String type="1";
    private int max=188;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);// 无标题
        setContentView(R.layout.activity_peidai);
        StatusBarCompat.translucentStatusBar(this);//沉浸状态栏
        ll_pd= (LinearLayout) findViewById(R.id.ll_pd);
        tv_pd= (TextView) findViewById(R.id.tv_pd);
        tv_pd.setOnClickListener(this);
        tv_pd_title= (TextView) findViewById(R.id.tv_pd_title);
        tv_pd_details= (TextView) findViewById(R.id.tv_pd_details);
        rl_view= (RelativeLayout) findViewById(R.id.rl_view);
        circularRingPercentageView= (CircularRingPercentageView) findViewById(R.id.circularRingPercentageView);
        tv_xl= (TextView) findViewById(R.id.tv_xl);

        //setProgress本来是填0-100的，现在如果最大值不是100，比如定义一个max为188，心率为57
        circularRingPercentageView.setProgress(Float.parseFloat(tv_xl.getText().toString())/max*100);

        tv_back= (TextView) findViewById(R.id.tv_back);
        tv_dangqian= (TextView) findViewById(R.id.tv_dangqian);
        tv_back.setTextSize(TypedValue.COMPLEX_UNIT_SP, DensityUtils.px2sp(PeidaiActivity.this,48));
        tv_pd_title.setTextSize(TypedValue.COMPLEX_UNIT_SP, DensityUtils.px2sp(PeidaiActivity.this,60));
        tv_pd_details.setTextSize(TypedValue.COMPLEX_UNIT_SP, DensityUtils.px2sp(PeidaiActivity.this,48));
        tv_pd.setTextSize(TypedValue.COMPLEX_UNIT_SP, DensityUtils.px2sp(PeidaiActivity.this,48));
        tv_xl.setTextSize(TypedValue.COMPLEX_UNIT_SP, DensityUtils.px2sp(PeidaiActivity.this,72));
        tv_bmp= (TextView) findViewById(R.id.tv_bmp);
        tv_bmp.setTextSize(TypedValue.COMPLEX_UNIT_SP, DensityUtils.px2sp(PeidaiActivity.this,40));
        tv_dangqian.setTextSize(TypedValue.COMPLEX_UNIT_SP, DensityUtils.px2sp(PeidaiActivity.this,40));
        tv_max_xl= (TextView) findViewById(R.id.tv_max_xl);
        tv_max_xl.setTextSize(TypedValue.COMPLEX_UNIT_SP, DensityUtils.px2sp(PeidaiActivity.this,40));
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_pd:
                switch (type){
                    case "1":
                        type="2";
                        tv_pd_title.setVisibility(View.VISIBLE);
                        tv_pd_title.setText(getResources().getString(R.string.pd_text_four));
                        tv_pd_details.setText(getResources().getString(R.string.pd_text_five));
                        tv_pd.setText(getResources().getString(R.string.pd_text_eight));
                        ll_pd.setVisibility(View.VISIBLE);
                        rl_view.setVisibility(View.GONE);
                        break;
                    case "2":
                        type="3";
                        tv_pd_title.setVisibility(View.VISIBLE);
                        tv_pd_title.setText(getResources().getString(R.string.pd_text_six));
                        tv_pd_details.setText(getResources().getString(R.string.pd_text_seven));
                        ll_pd.setVisibility(View.GONE);
                        rl_view.setVisibility(View.VISIBLE);
                        //setProgress本来是填0-100的，现在如果最大值不是100，比如定义一个max为188，心率为57
                        circularRingPercentageView.setProgress(Float.parseFloat(tv_xl.getText().toString())/max*100);
                        tv_max_xl.setVisibility(View.VISIBLE);
                        break;
                    case "3":
                        break;
                }
                break;
        }

    }
}
